﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mystery.SharePoint
{
    /// <summary>
    /// Implements a Site Provisioning Provider that allows only members to provision site collections
    /// </summary>
    internal class MemberSiteProvisioningAuthenticationProvider : ISiteProvisioningAuthenticationProvider
    {
        public string Name
        {
            get { return Resources.SiteProvisioningProvier_Member_Name; }
        }

        public bool CanProvision(Microsoft.SharePoint.SPSite context, Microsoft.SharePoint.SPUser user)
        {
            if (context.RootWeb.AssociatedMemberGroup == null)
            {
                return false;
            }
            if (context.RootWeb.AssociatedMemberGroup.Users.FindByLogin(user.LoginName) != null)
            {
                return true;
            }
            return false;
        }  
    }
}
